#include "pathconvert.h"
#include<stdlib.h>
#include<string.h>

char *pathconvert(const char *path1, const char *path2)
{
    int len1 = strlen(path1);
    int len2 = strlen(path2);
    char *convertedpath = malloc(sizeof(char) * (len1 + len2 + 3));
    int index;
    for (index = len1; index >= 0; index--)
    {
        if (path1[index] == '/')
        {
            break;
        }
    }
    index++;
    strcpy(convertedpath, path2);
    if (path2[len2 - 1] != '/')
    {
        //检查路径2是否以 "/" 结尾, 若否, 则应补全路径符号, 再补全文件名
        strcat(convertedpath, "/");
    }
    strcat(convertedpath, path1 + index);
    return convertedpath;
}